package edu.zzuli.model.xt.jqqx.zzjggl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import edu.zzuli.common.MyVisit;
import edu.zzuli.common.TreeNode;
import edu.zzuli.model.xt.jqqx.zzjggl.iface.ZzjgglService;

/**
 * @author tianshaojie
 * @date 2011-1-16
 * @discription : 
 */
@Controller
public class ShowZzjgTreeAction {
	
	@Resource
	private ZzjgglService zzjgglService;
	
	private String czlbId;
	
	private String xtgns;
	
	private String ajaxResult;
	
	private List<TreeNode> treeNodes;
	
	public String execute() {
		//MyVisit myVisit = (MyVisit) ActionContext.getContext().getSession().get("myVisit");
//		String sid = ServletActionContext. getRequest().getSession().getId();
		MyVisit myVisit = (MyVisit) ServletActionContext. getRequest().getSession().getAttribute("myVisit");
		this.treeNodes = this.zzjgglService.getZzjgTree(myVisit.getGG_JGBH().getJgbh());
		ajaxResult = "success";
		return ajaxResult;
	}
	
	public String delete() {
		String jgbh = ServletActionContext.getRequest().getParameter("jgbh");
		try {
			if (jgbh != null && !"".equals(jgbh)) {
				this.zzjgglService.deleteGG_JGBH(jgbh);
				this.ajaxResult = "success";
			} else {
				this.ajaxResult = "error";
			}
		} catch (Exception e) {
			e.printStackTrace();
			this.ajaxResult = "error";
		}
		return this.ajaxResult;
	}

	public void setCzlbId(String czlbId) {
		this.czlbId = czlbId;
	}
	public String getCzlbId() {
		return czlbId;
	}
	public void setTreeNodes(List<TreeNode> treeNodes) {
		this.treeNodes = treeNodes;
	}

	public List<TreeNode> getTreeNodes() {
		return treeNodes;
	}
	
	public void setAjaxResult(String ajaxResult) {
		this.ajaxResult = ajaxResult;
	}
	
	public String getAjaxResult() {
		return ajaxResult;
	}
	
	public void setXtgns(String xtgns) {
		this.xtgns = xtgns;
	}
	
	public String getXtgns() {
		return xtgns;
	}
}
